package org.suyafei.strategy;

import org.springframework.context.annotation.Configuration;

import java.util.*;

/**
 * @author 宿某人
 * @Date: 2021/12/21/2:29 下午
 * @Description:
 */
@Configuration
public class ShardingTableConfig {
    /**
     * 存储数据位置编号
     */
    private static List<String> tableSuffixList = new ArrayList<>();
    static {
        tableSuffixList.add("0");
        tableSuffixList.add("a");
    }

    /**
     * 轮询获取
     * @return
     */
    public static String getPollingBPrefix(String code) {
        int hashCode = code.hashCode();
        int index = Math.abs(hashCode) % tableSuffixList.size();
        return tableSuffixList.get(index);
    }
}
